/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

jQuery(document).ready(function () {
    $('#supplier').change(function(){
        $.ajax({
            type: "POST",
            url : base_url+'?r=shop/shoppingCart/choseDistributor',
            async: false,
            cache: false,
            data: {'supplier':$(this).val()
                       },
                            success: function(string){
                                var data = $.parseJSON(string);
                                var content = "<select id='distributor' name=distributor>"
                                $.each(data, function(index, array) {
                                    content = content + "<option value=" + array + ">" + index + "</option>";
                                });
                                content = content + "</select>";
                                $(content).replaceAll('#distributor');
                            }
        });
    });
    });
